package com.ihr360.payroll.dao;

import com.ihr360.payroll.model.dto.attendance.report.AttendanceBill;
import com.ihr360.rest.reposity.SimpleRestReposity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.Collection;
import java.util.Date;
import java.util.List;

@RepositoryRestResource
public interface AttendanceBillRepository extends SimpleRestReposity<AttendanceBill, Long> {
    /**
     * 获取某个时间范围内的日报信息
     *
     * @return
     */
    @Query(value = "select * from attendancebill where companyId=:companyId and salaryPlanId=:salaryPlanId and reportDate between :startDate and :endDate and  staffId in :staffIds", nativeQuery = true)
    List<AttendanceBill> findDailyReportOfStaffsInAPeriod(@Param(value = "companyId") String companyId, @Param(value = "salaryPlanId") Long salaryPlanId, @Param(value = "startDate") Date startDate, @Param(value = "endDate") Date endDate, @Param(value = "staffIds") Collection<String> staffIds);

    List<AttendanceBill> findByCompanyIdAndStaffInfoStaffIdAndMonthlyReportIdInAndReportType(String companyId, String staffId, List<Long> monthlyReportIdList, String type);

    List<AttendanceBill> findByCompanyIdAndMonthlyReportIdInOrderByReportDate(String companyId, List<Long> monthlyReportIdList);
}